<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE HTML>
<ui:composition template="/dinamic/template/template.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

	<ui:define name="conteudo">
		<h:form id="form" prependId="false">
			<p:panel id="panel" rendered="false">
					<p:outputLabel value="Titulo : " />
					<br/>
					<p:inputText value="#{postagemManagedBean.postagem.titulo}" size="60" maxlength="60"/>
					<br/>
					<p:outputLabel value="Assunto(s) : " />
	        			<p:autoComplete id="nomeAssunto" value="#{postagemManagedBean.postagem.assuntos}" maxResults="5" completeMethod="#{postagemManagedBean.completeNomeAssunto}" size="60" maxlength="60" multiple="true" converter="#{assuntoConverter}"/>
					<br />
					<p:editor id="editor1" value="#{postagemManagedBean.postagem.mensagem}"
						width="600" />
					<p:commandButton value="Postar !"
						action="#{postagemManagedBean.incluirPostagem()}" ajax="false" >
						<f:setPropertyActionListener target="#{postagemManagedBean.postagem}" value="#{postagemManagedBean.postagem}"/>
						</p:commandButton>
						
				</p:panel>
				
			<p:panel id="panel2" rendered="true">
				<p:outputLabel value="Titulo : " />
				<br/>
				<p:inputText value="#{postagemManagedBean.postagem.titulo}" size="60" maxlength="60"/>
				<br/>
				<p:outputLabel value="Assunto(s) : " />
        			<p:autoComplete id="nomeAssunto2" value="#{postagemManagedBean.postagem.assuntos}" maxResults="5" completeMethod="#{postagemManagedBean.completeNomeAssunto}" size="60" maxlength="60" multiple="true" converter="#{assuntoConverter}"/>
				<br />
				
			<div id="idTag">
				<p:commandButton update="panel2" value="[code]" onclick="getTextSelection()" actionListener="#{postagemManagedBean.addTag}">
					<f:param name="button" value="1"/>
				</p:commandButton>
				
				<p:commandButton update="panel2" value="[B]" onclick="getTextSelection()" actionListener="#{postagemManagedBean.addTag}">
					<f:param name="button" value="2"/>
				</p:commandButton>
				
				<p:commandButton update="panel2" value="[I]" onclick="getTextSelection()" actionListener="#{postagemManagedBean.addTag}">
					<f:param name="button" value="3"/>
				</p:commandButton>
				
				<p:commandButton update="panel2" value="[S]" onclick="getTextSelection()" actionListener="#{postagemManagedBean.addTag}">
					<f:param name="button" value="4"/>
				</p:commandButton>
			</div>
			
			<br/>		
				
				<p:inputTextarea  id="editor" value="#{postagemManagedBean.postagem.mensagem}" rows="15" cols="90"/>
				<h:inputHidden id="posicaoInicialHidden" value="#{postagemManagedBean.posicaoInicial}" />
				<h:inputHidden id="posicaoFinalHidden" value="#{postagemManagedBean.posicaoFinal}" />
				
				<br/>
				
				<p:commandButton value="Limpar" actionListener="#{postagemManagedBean.reset()}" immediate="true" ajax="false">
					<p:resetInput target="panel2"></p:resetInput>
				</p:commandButton>
				
				<p:commandButton value="Postar !"
					action="#{postagemManagedBean.incluirPostagem()}" ajax="false" >
					<f:setPropertyActionListener target="#{postagemManagedBean.postagem}" value="#{postagemManagedBean.postagem}"/>
				</p:commandButton>
					
			</p:panel>
		</h:form> 
	</ui:define>
</ui:composition>